package com.sugon.service.impl;

import cn.hutool.core.util.RandomUtil;
import com.sugon.dao.DevRecordOptionDao;
import com.sugon.entity.DevRecordOptionEntity;
import com.sugon.service.DevRecordOptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import static com.sugon.utils.ShiroUtils.getUserId;

/**
 * 巡检记录选项关联Service实现类
 *
 * @author sugon
 * @date 2019-09-24 11:21:34
 */
@Service("devRecordOptionService")
public class DevRecordOptionServiceImpl implements DevRecordOptionService {
    @Autowired
    private DevRecordOptionDao devRecordOptionDao;

    @Override
    public DevRecordOptionEntity queryObject(String id) {
        return devRecordOptionDao.queryObject(id);
    }

    @Override
    public List<DevRecordOptionEntity> queryList(Map<String, Object> map) {
        return devRecordOptionDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return devRecordOptionDao.queryTotal(map);
    }

    @Override
    public int save(DevRecordOptionEntity devRecordOption) {
        devRecordOption.setId(RandomUtil.randomString(32));
        return devRecordOptionDao.save(devRecordOption);
    }

    @Override
    public int update(DevRecordOptionEntity devRecordOption) {
        return devRecordOptionDao.update(devRecordOption);
    }

    @Override
    public int delete(String id) {
        return devRecordOptionDao.delete(id);
    }

    @Override
    public int deleteBatch(String[] ids) {
        return devRecordOptionDao.deleteBatch(ids);
    }

    @Override
    public int saveRecordOption() {
        return 0;
    }

    @Override
    public int deal(DevRecordOptionEntity devRecordOption) {
        devRecordOption.setPlanUser(getUserId());
        devRecordOption.setPlanDate(new Date());
        return devRecordOptionDao.update(devRecordOption);
    }
}
